package com.baseServlet;



import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@SuppressWarnings("serial")
public class BaseServlet extends HttpServlet {
	protected ObjectMapper mapper=new ObjectMapper();
	protected Map<String,Object> map;
	
	
	
	public ObjectMapper getMapper() {
		return mapper;
	}
	public void setMapper(ObjectMapper mapper) {
		this.mapper = mapper;
	}
	public Map<String, Object> getMap() {
		return map;
	}
	public void setMap(Map<String, Object> map) {
		this.map = map;
	}
	protected void toJson(HttpServletResponse resp,Object object) {
		String json;
		try {
			json=mapper.writeValueAsString(object);
			PrintWriter out=resp.getWriter();
			System.out.println("json="+json);
			out.print(json);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
	public void init() throws ServletException {
		
	}

}
